#ifndef ZSHADER_H_
#define ZSHADER_H_

#include "../Common/GlobalDefines.h"

#ifdef RENDER_OPENGL

#include <QGLShaderProgram>
GLOBAL_NAMESPACE_BEGIN

enum GLShaderType {
    SHADER_GL_Vertex    = QGLShader::Vertex,
    SHADER_GL_Fragment  = QGLShader::Fragment,
    SHADER_GL_Geometry  = QGLShader::Geometry,
    SHADER_UNDEFINED = -1
};

class GLShader
{
public:
    GLShader(const GLShaderType& type = SHADER_UNDEFINED);
    GLShader(const GLShaderType& type, const char* shaderSrc, const char* shaderName);
    ~GLShader();

    QGLShader*      getShader();
    GLShaderType    getShaderType();
    std::string     getShaderName();
    void            bind(QWidget* parent);

    static GLShader* getDefaultShader(const GLShaderType& tpye);

private:
    void init();
    void destroy();

    void static_init();
    void createDefaultVertexShader();
    void createDefaultFragmentShader();
    void createDefaultGeometryShader();

private:
    std::string     shaderName_;
    std::string     shaderSrc_;
    GLShaderType    type_;
    QGLShader*      shader_;
};

static GLShader defaultVertexShader(SHADER_GL_Vertex);
static GLShader defaultFragmentShader(SHADER_GL_Fragment);
static GLShader defaultGeometryShader(SHADER_GL_Geometry);

GLOBAL_NAMESPACE_END

#endif

#endif//ZSHADER_H_